package com.ktjy.test;

import com.ktjy.entity.Supplier;
import com.ktjy.entity.SysUser;
import com.ktjy.service.SysUserService;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class Main {

    Logger logger = LoggerFactory.getLogger(Main.class);
    @Test
    public void test1(){
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");

        SysUserService userService = (SysUserService) context.getBean("sysUserService");

        SysUser queryCondition = new SysUser();
        queryCondition.setRealName("李");
        queryCondition.setRoleId(2L);
        List<SysUser> userList = userService.getSysUserList(queryCondition);

        for (SysUser user : userList) {
            logger.info("SysUser:account={}，realName={}，roleName={}",
                    user.getAccount(), user.getRealName(),user.getSysRole().getRoleName());
        }
    }

    @Test
    public void test2(){
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        SysUserService userService = (SysUserService) context.getBean("sysUserService");

        Supplier supplier = new Supplier();
        supplier.setSupName("湖南小吃连锁有限公司");

        List<Supplier> suppliers = userService.getSupplierList(supplier);

        for (Supplier s : suppliers) {
            System.out.println(s);
        }
    }
}
